<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 25] 25.21 java.lang.Float (JDK 1.0)</TITLE>
<META NAME="author" CONTENT="David Flanagan">
<META NAME="date" CONTENT="Thu Jul 31 16:26:52 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java">
<META NAME="title" CONTENT="Java in a Nutshell">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java in a Nutshell" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch25_20.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 25<br>The java.lang Package</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch25_22.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=sect1>
<h2 CLASS=sect1><A CLASS="TITLE" NAME="JNUT2-CH-25-SECT-21">25.21 java.lang.Float (JDK 1.0)</A></h2>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-25-SECT-21.1"></A></h3>
</DIV>

<P CLASS=para>
This class provides an immutable object wrapper around the
<tt CLASS=literal>float</tt> primitive data type.
<tt CLASS=literal>valueOf()</tt> converts a string to a <tt CLASS=literal>Float</tt>,
<tt CLASS=literal>floatValue()</tt> returns the primitive <tt CLASS=literal>float</tt>
value of a <tt CLASS=literal>Float</tt> object, 
and there are methods for returning a <tt CLASS=literal>Float</tt>
value as a variety of other primitive types.

<P CLASS=para>
This class also provides some useful constants and static
methods for testing <tt CLASS=literal>float</tt> values. <tt CLASS=literal>MIN_VALUE</tt>
and <tt CLASS=literal>MAX_VALUE</tt> are the smallest (closest to zero) and
largest representable <tt CLASS=literal>double</tt> values.
<tt CLASS=literal>isInfinite()</tt> in class method and instance method
forms tests whether a <tt CLASS=literal>float</tt> or a <tt CLASS=literal>Float</tt> has
an infinite value. Similarly, <tt CLASS=literal>isNaN()</tt> tests whether
a <tt CLASS=literal>float</tt> or <tt CLASS=literal>Float</tt> is not-a-number--this is a
comparison that cannot be done directly because the
<tt CLASS=literal>NaN</tt> constant never tests equal to any other value,
including itself. <tt CLASS=literal>floatToIntBits()</tt> and
<tt CLASS=literal>intBitsToFloat()</tt> allow you to manipulate the bit
representation of a <tt CLASS=literal>float</tt> directly.

<DIV CLASS=screen>
<P>
<PRE>
public final class <tt CLASS=literal>Float</tt> extends Number {
    // <tt CLASS=literal>Public Constructors</tt>
            public <tt CLASS=literal>Float</tt>(float <tt CLASS=literal>value</tt>);
            public <tt CLASS=literal>Float</tt>(double <tt CLASS=literal>value</tt>);
            public <tt CLASS=literal>Float</tt>(String <tt CLASS=literal>s</tt>) throws NumberFormatException;
    // <tt CLASS=literal>Constants</tt>
            public static final float <tt CLASS=literal>MAX_VALUE</tt>;
            public static final float <tt CLASS=literal>MIN_VALUE</tt>;
            public static final float <tt CLASS=literal>NEGATIVE_INFINITY</tt>;
            public static final float <tt CLASS=literal>NaN</tt>;
            public static final float <tt CLASS=literal>POSITIVE_INFINITY</tt>;
        <b>1.1</b>public static final Class <tt CLASS=literal>TYPE</tt>;
    // <tt CLASS=literal>Class Methods</tt>
            public static native int <tt CLASS=literal>floatToIntBits</tt>(float <tt CLASS=literal>value</tt>);
            public static native float <tt CLASS=literal>intBitsToFloat</tt>(int <tt CLASS=literal>bits</tt>);
            public static boolean <tt CLASS=literal>isInfinite</tt>(float <tt CLASS=literal>v</tt>);
            public static boolean <tt CLASS=literal>isNaN</tt>(float <tt CLASS=literal>v</tt>);
            public static String <tt CLASS=literal>toString</tt>(float <tt CLASS=literal>f</tt>);
            public static Float <tt CLASS=literal>valueOf</tt>(String <tt CLASS=literal>s</tt>) throws NumberFormatException;
    // <tt CLASS=literal>Public Instance Methods</tt>
        <b>1.1</b>public byte <tt CLASS=literal>byteValue</tt>();  //<tt CLASS=literal> Overrides Number</tt>
            public double <tt CLASS=literal>doubleValue</tt>();  //<tt CLASS=literal> Defines Number</tt>
            public boolean <tt CLASS=literal>equals</tt>(Object <tt CLASS=literal>obj</tt>);  //<tt CLASS=literal> Overrides Object</tt>
            public float <tt CLASS=literal>floatValue</tt>();  //<tt CLASS=literal> Defines Number</tt>
            public int <tt CLASS=literal>hashCode</tt>();  //<tt CLASS=literal> Overrides Object</tt>
            public int <tt CLASS=literal>intValue</tt>();  //<tt CLASS=literal> Defines Number</tt>
            public boolean <tt CLASS=literal>isInfinite</tt>();
            public boolean <tt CLASS=literal>isNaN</tt>();
            public long <tt CLASS=literal>longValue</tt>();  //<tt CLASS=literal> Defines Number</tt>
        <b>1.1</b>public short <tt CLASS=literal>shortValue</tt>();  //<tt CLASS=literal> Overrides Number</tt>
            public String <tt CLASS=literal>toString</tt>();  //<tt CLASS=literal> Overrides Object</tt>
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-25-SECT-21.2">Hierarchy:</A></h3>

<P CLASS=para>
Object->Number(Serializable)->Float

</DIV>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JNUT2-CH-25-SECT-21.3">Returned By:</A></h3>

<P CLASS=para>
Float.valueOf()

</DIV>

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch25_20.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch25_22.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>java.lang.ExceptionInInitializerError (JDK 1.1)</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>java.lang.IllegalAccessError (JDK 1.0)</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
